package xq.gwt.ui.rpc;

import xq.gwt.ui.widgets.feedback.DefaultExceptionPresenter;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;

public abstract class AsyncCallbackAdapter<T> implements AsyncCallback<T> {
    @Override
    public void onFailure(Throwable caught) {
        if (caught instanceof InvocationException) {
            InvocationException ie = (InvocationException) caught;
            if(ie.getMessage().contains("j_spring_security_check"))
            {               	
                String logoutUrl = GWT.getHostPageBaseURL() + "j_spring_security_logout";
        		com.google.gwt.user.client.Window.Location.assign(logoutUrl);
                return;
            }
        }
        //Other general exceptions
        Exception ex = new Exception(caught.getMessage());
		DefaultExceptionPresenter exPresenter = new DefaultExceptionPresenter();
		exPresenter.showException(ex);
    
    }
}